package com.example.color_game;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.KeyEvent;
import android.view.Menu;

import com.colorgame.connection.SimpleBluetooth;
//import com.colorgame.connection.bluetooth;
import com.colorgame.main.GameController;
import com.colorgame.main.GameInstance;

public class MainActivity extends Activity {
	GameController gc;
	GameInstance gi;
	int lay = -1;
	
	public static int displayWidth;
	public static int displayHeight;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		SimpleBluetooth.activity = this;
		
		
		Display display = getWindowManager().getDefaultDisplay();
		displayWidth = display.getWidth();
		displayHeight = display.getHeight();
		gc = new GameController(this);	
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	
	
		if (keyCode == KeyEvent.KEYCODE_BACK) {

			if (getContentView() == R.layout.layout_game) {
				gc.closeGameInstance();
			}
			
			if (getContentView() == R.layout.layout_menu) {
				finish();
			} else {				
				gc.Init();
				return true;
			}
			
		}


		return super.onKeyDown(keyCode, event);
	}
	
	@Override
	public void setContentView(int layoutResID) {
		super.setContentView(layoutResID);
		
		lay = layoutResID;
	}
	
	public int getContentView() {
		return lay;
	}
	
		
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		
		SimpleBluetooth.onActivityResult(requestCode, resultCode, data);
	}
	
	

}
